package com.app.shop.config.security;

import com.app.shop.util.UserEntity;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.context.SecurityContextHolder;

/**
 * 用户支撑类 * @author Dongguabai * @date 2018-07-12 23:03
 */
public class DgbSecurityUserHelper {
    /**
     * 获取当前用户     * @return
     */
    public static Authentication getCurrentUserAuthentication() {
        return SecurityContextHolder.getContext().getAuthentication();
    }

    /**
     * 获取当前用户     * @return
     */
    public static Object getCurrentPrincipal() {
        return getCurrentUserAuthentication().getPrincipal();
    }

    /**
     * 用户当前用户实体类
     * @return
     */
    public static UserEntity getUserInfo(){
        return ((UserEntity)getCurrentPrincipal());
    }
}
